import { createSlice } from '@reduxjs/toolkit';
import { permission, userlist } from '../../utils/types/home';
const login = createSlice({
  name: 'login',
  initialState: {
    userlist: [] as userlist[],
    permission: JSON.parse(localStorage.getItem('userlist')) as permission[],
  },
  reducers: {
    adduserlist(state, actions: any) {
      state.userlist = actions.payload;
      // console.log(state.userlist);

      //     state是上面的数据 通过state.num来赋值
      //     action是传递的参数，需要使用actions.payload来获取
      //     当是数组的时候，需要进行浅拷贝
      //      const copylist =  [...state.list]
    },
    addpermission(state, actions: any) {
      state.permission = actions.payload;
      // console.log(state.permission);
    },
  },
});
export const { adduserlist, addpermission } = login.actions;
export default login;
